package com.night.card.controller;

import com.github.pagehelper.PageInfo;
import com.night.card.service.interfs.CadOutMachineService;
import com.night.card.vo.CardDataVo;
import com.night.common.entity.ResultVo;
import com.night.common.entity.card.CardOutMachine;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName: CardOutController
 * @Description: CardOutController
 * @author: CHX42
 * @date: 2022/10/25-10:43
 * @version: v1.0
 */
@RestController
@RequestMapping("/api/cardOut/")
public class CardOutController {
    @Resource
    private CadOutMachineService cadOutMachineService;

    @PostMapping("/add")
    public ResultVo<?> add(@RequestBody CardOutMachine cardOutMachine) {
        cadOutMachineService.add(cardOutMachine);
        return ResultVo.SUCCESS;
    }

    @PostMapping("/list")
    public ResultVo<?> list(@RequestBody CardDataVo<CardOutMachine, CardOutMachine> cardOutMachineDataVo) {
        PageInfo<CardOutMachine> machinePageInfo = cadOutMachineService.getBy(cardOutMachineDataVo.getPageInfo());
        return new ResultVo<>(machinePageInfo);
    }

    @PostMapping("/update")
    public ResultVo<?> update(@RequestBody CardOutMachine cardOutMachine) {
        cadOutMachineService.update(cardOutMachine);
        return ResultVo.SUCCESS;
    }

    @PostMapping("/getById")
    public ResultVo<?> getById(@RequestBody CardOutMachine cardOutMachine) {
        cadOutMachineService.add(cardOutMachine);
        return ResultVo.SUCCESS;
    }
}
